package database

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"github.com/neo4j/neo4j-go-driver/v5/neo4j"
)

func CreateNeo4jDriver() neo4j.DriverWithContext {
	jsonString, _ := ioutil.ReadFile(neo4jPath)
	config := make(map[string]string)
	json.Unmarshal(jsonString, &config)
	fmt.Printf("url: %s\nname: %s\npassword: %s\n", config["url"], config["name"], config["password"])
	driver, err := neo4j.NewDriverWithContext(
		config["url"], 
		neo4j.BasicAuth(config["name"], config["password"], ""),
	)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(-1)
	}
	return driver
}

